﻿namespace Smart.ERP
{
    using Smart.Data.Helper;
    using System;
    using System.Data.SqlClient;

    internal class LICENSE
    {
        private bool m_Active;
        private DateTime m_DateActive;
        private int m_Id_License;
        private int m_Id_Soft;
        private string m_KeyCode;
        private string m_MachineCode;
        private int m_ReActive;
        private string m_Version;

        public LICENSE()
        {
            this.m_Id_License = 0;
            this.m_Id_Soft = 0;
            this.m_KeyCode = "";
            this.m_MachineCode = "";
            this.m_Active = true;
            this.m_Version = "";
            this.m_DateActive = DateTime.Now;
            this.m_ReActive = 0;
        }

        public LICENSE(int Id_License, int Id_Soft, string KeyCode, string MachineCode, bool Active, string Version, DateTime DateActive, int ReActive)
        {
            this.m_Id_License = Id_License;
            this.m_Id_Soft = Id_Soft;
            this.m_KeyCode = KeyCode;
            this.m_MachineCode = MachineCode;
            this.m_Active = Active;
            this.m_Version = Version;
            this.m_DateActive = DateActive;
            this.m_ReActive = ReActive;
        }

        public string Get(string KeyCode, string MachineCode)
        {
            string str = "";
            string[] myParams = new string[] { "@KeyCode", "@MachineCode" };
            object[] myValues = new object[] { KeyCode, MachineCode };
            SqlHelper helper = new SqlHelper("HPqrGX/piQz0Xe4u/h/67gQ3uyF/l8Jnvceflfn0g5a097J0Dujgoj8bqG7F7buoYB2Mt+NKyXJ77rNdpJJ69tNga+CVb/KOMzARhvb5JWkXymCWnUJWzzgLCgblpEMy", "07071983", true);
            SqlDataReader reader = helper.ExecuteReader("LICENSE_GetMachKeyCode", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Id_License = Convert.ToInt32(reader["Id_License"]);
                    this.m_KeyCode = Convert.ToString(reader["KeyCode"]);
                    this.m_MachineCode = Convert.ToString(reader["MachineCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    this.m_Version = Convert.ToString(reader["Version"]);
                    this.m_DateActive = Convert.ToDateTime(reader["DateActive"]);
                    this.m_ReActive = Convert.ToInt32(reader["ReActive"]);
                    str = "OK";
                }
                reader.Close();
                reader.Dispose();
                helper.Close();
            }
            return str;
        }

        public string Insert(string NameSoft, string KeyCode, string MachineCode, bool Active, string Version)
        {
            string[] myParams = new string[] { "@NameSoft", "@KeyCode", "@MachineCode", "@Active", "@Version" };
            object[] myValues = new object[] { NameSoft, KeyCode, MachineCode, Active, Version };
            SqlHelper helper = new SqlHelper("HPqrGX/piQz0Xe4u/h/67gQ3uyF/l8Jnvceflfn0g5a097J0Dujgoj8bqG7F7buoYB2Mt+NKyXJ77rNdpJJ69tNga+CVb/KOMzARhvb5JWkXymCWnUJWzzgLCgblpEMy", "07071983", true);
            return helper.ExecuteNonQuery("LICENSE_InsertName", myParams, myValues);
        }

        public string Update(string KeyCode, string MachineCode)
        {
            string[] myParams = new string[] { "@KeyCode", "@MachineCode" };
            object[] myValues = new object[] { KeyCode, MachineCode };
            SqlHelper helper = new SqlHelper("HPqrGX/piQz0Xe4u/h/67gQ3uyF/l8Jnvceflfn0g5a097J0Dujgoj8bqG7F7buoYB2Mt+NKyXJ77rNdpJJ69tNga+CVb/KOMzARhvb5JWkXymCWnUJWzzgLCgblpEMy", "07071983", true);
            return helper.ExecuteNonQuery("LICENSE_UpdateReActive", myParams, myValues);
        }

        public bool Active
        {
            get
            {
                return this.m_Active;
            }
            set
            {
                this.m_Active = value;
            }
        }

        public DateTime DateActive
        {
            get
            {
                return this.m_DateActive;
            }
            set
            {
                this.m_DateActive = value;
            }
        }

        public int Id_License
        {
            get
            {
                return this.m_Id_License;
            }
            set
            {
                this.m_Id_License = value;
            }
        }

        public int Id_Soft
        {
            get
            {
                return this.m_Id_Soft;
            }
            set
            {
                this.m_Id_Soft = value;
            }
        }

        public string KeyCode
        {
            get
            {
                return this.m_KeyCode;
            }
            set
            {
                this.m_KeyCode = value;
            }
        }

        public string MachineCode
        {
            get
            {
                return this.m_MachineCode;
            }
            set
            {
                this.m_MachineCode = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class LICENSE";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public int ReActive
        {
            get
            {
                return this.m_ReActive;
            }
            set
            {
                this.m_ReActive = value;
            }
        }

        public string Version
        {
            get
            {
                return this.m_Version;
            }
            set
            {
                this.m_Version = value;
            }
        }
    }
}

